package com.lechi.web.controller;

import com.lechi.web.common.annotation.Log;
import com.lechi.web.common.core.controller.BaseController;
import com.lechi.web.common.core.domain.AjaxResult;
import com.lechi.web.common.core.page.TableDataInfo;
import com.lechi.web.common.enums.BusinessType;
import com.lechi.web.common.utils.bean.BeanUtils;
import com.lechi.web.system.domain.IotInterfaceApiBo;
import com.lechi.web.system.service.IIotInterfaceApiService;
import com.lechi.web.vo.IotInterfaceApiVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 接口发布管理Controller
 *
 * @author yangguang
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/iot/interface/api")
public class IotInterfaceApiController extends BaseController {

    @Autowired
    private IIotInterfaceApiService iotInterfaceApiService;

    /**
     * 查询接口发布管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(IotInterfaceApiVo iotInterfaceApiVo) {
        startPage();
        IotInterfaceApiBo iotInterfaceApi = new IotInterfaceApiBo();
        BeanUtils.copyProperties(iotInterfaceApiVo, iotInterfaceApi);
        List<IotInterfaceApiBo> list = iotInterfaceApiService.selectIotInterfaceApiList(iotInterfaceApi);
        return getDataTable(list);
    }

    /**
     * 修改接口发布管理
     */
    @Log(title = "接口修改", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody IotInterfaceApiVo iotInterfaceApiVo) {
        IotInterfaceApiBo iotInterfaceApi = new IotInterfaceApiBo();
        BeanUtils.copyProperties(iotInterfaceApiVo, iotInterfaceApi);
        iotInterfaceApiService.updateIotInterfaceApi(iotInterfaceApi);
        return AjaxResult.success();
    }
}
